#define _CRT_SECURE_NO_WARNINGS 1


#include <stdio.h>
#include <string.h>
int main() {
    int n;
    scanf("%d", &n);
    int i = 0;
    int j = 0;

    for (i = 0; i < n; i++)
    {
        int p=0, q=0, t=0;
        char a[100] = { '\0' };
        scanf("%s", a);
        int l = strlen(a);
        if (l < 8)
        {
            printf("NO\n");
            continue;
        }
        for (j = 0; j < l; j++)
        {
            if (a[j] >= '0' && a[j] <= '9')
            {
                t = 1;
                continue;
            }
            if (a[j] >= 'a' && a[j] <= 'z')
            {
                q = 1;
                continue;
            }
            if (a[j] >= 'A' && a[j] <= 'Z')
            {
                p = 1;
                continue;
            }
            printf("NO\n");
            continue;

        }
        if ((a[j] >= '0' && a[j] <= '9') || (t + q + p) < 2)
        {
            printf("NO\n");
            continue;
        }
        printf("YES\n");
    }

    return 0;
}